package diamondRingService.impl;

import diamondRingDao.impl.UserDaoImpl;
import diamondRingEntity.User;
import diamondRingEntity.DiamondRingUser;
import diamondRingService.UserService;

public class UserServiceImpl implements UserService {
    UserDaoImpl adm=new UserDaoImpl();
    @Override
    public int Login(User user) {
        int count=0;
        try {
            if (null != user){
                //把数据送到数据访问层
                count=adm.Login(user);
            }else {
                count = -1;
            }
        } catch (Exception e) {
            System.err.println("业务逻辑层"+e);
        }
        return count;
    }

    @Override
    public int Regist(User user) {
        int count=0;
        try {
            if (null != user){
                //把数据送到数据访问层
                count=adm.Regist(user);
            }
        } catch (Exception e) {
            System.err.println("业务逻辑层"+e);
        }
        return count;
    }

    @Override
    public int isRegist(User user) {
        int count=0;
        try {
            if (null != user){
                //把数据送到数据访问层
                count=adm.isRegist(user);
            }
        } catch (Exception e) {
            System.err.println("业务逻辑层"+e);
        }
        return count;
    }

    @Override
    public DiamondRingUser findUser(String email, int pwd) {
        DiamondRingUser count=null;
            count=adm.findUser(email,pwd);
        return count;
    }

    @Override
    public int userUpdatePwd(int userid, int oldPwd, int newPwd) {
        int count=0;
        if (userid>0){
            count=adm.userUpdatePwd(userid,oldPwd,newPwd);
        }else {
            count=-1;
        }
        return count;
    }
}
